'''
Created on Nov 21, 2009

@author: anch
'''
import unittest
import resource_manager
import testcase.game_model_test as model
import interface.ConsoleAgent as CA
import ai.human as human

class Test(unittest.TestCase):


	def testGetMovablePieces(self):
		state = resource_manager.ResourceManager\
			.constructStateMap('abel.txt', \
				model.Test.getPlayer0(), model.Test.getPlayer1())
#		CA.ConsoleDescriptor.drawState(state)
		
		moves = state.successorMove()
		
		pieces = human.AIHuman.getMovablePieces(moves)
		
		self.assertEqual(len(pieces), 3)
		self.assertTrue((4,4) in pieces)
		self.assertTrue((5,3) in pieces)
		self.assertTrue((7,3) in pieces)
		pass
	
	def testGetAvailableDestination(self):
		state = resource_manager.ResourceManager\
			.constructStateMap('noah.txt', \
				model.Test.getPlayer0(), model.Test.getPlayer1())
		
#		CA.ConsoleDescriptor.drawState(state)
		
		moves = state.successorMove()
		
		#For piece (F, 5)
		destinations = human.AIHuman.getAvailableDestinations(moves, (5, 5))
		
		self.assertEqual(len(destinations), 4)
		self.assertTrue((3,7) in destinations)
		self.assertTrue((3,3) in destinations)
		self.assertTrue((7,7) in destinations)
		self.assertTrue((7,3) in destinations)
		
		#For piece (F, 7)
		destinations = human.AIHuman.getAvailableDestinations(moves, (5, 3))
		self.assertEqual(len(destinations), 2)
		self.assertTrue((3,5) in destinations)
		self.assertTrue((7,5) in destinations)
		
		pass

if __name__ == "__main__":
	#import sys;sys.argv = ['', 'Test.testGetMovablePieces']
	unittest.main()